const Koa = require("koa");
const axios = require("axios");
const router = require("koa-router")();
const app = new Koa();
//中间件  任何请求都要走这里
app.use((ctx, next) => {
  // console.log(ctx)
  next()
})
router.get('/search',async (ctx, next) => {
  // let searchKey = ctx.request.query.q
  const users=[
    {
      name:"xixi",
      age:18,
      id:0,
      avatar:"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=24336452,906724543&fm=26&gp=0.jpg"
    },
    {
      name:"haha",
      age:18,
      id:1,
      avatar:"https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1073244124,868127656&fm=26&gp=0.jpg"
    },
    {
      name:"qqq",
      age:18,
      id:2,
      avatar:"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1419628337,1603242413&fm=26&gp=0.jpg"
    },
    {
      name:"eee",
      age:18,
      id:3,
      avatar:"https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3762143736,532416092&fm=11&gp=0.jpg"
    },
    {
      name:"www",
      age:18,
      id:4,
      avatar:"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3869515018,2735128030&fm=26&gp=0.jpg"
    }
  ]
  ctx.body=users
})
app.use(router.routes());
app.use(router.allowedMethods());
app.listen(8888, () => {
  console.log('http://localhost:8888')
})